import java.io.IOException;
import java.util.*;


public class GDStatusCheck extends Thread{
	GroupDispatcher gd;
	public GDStatusCheck(GroupDispatcher d){
		gd = d;
	}
	@SuppressWarnings("null")
	public void run(){
		while(true){		
			
			//wait 500 ms
			try {
				Thread.sleep(500);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			
			//generate list of all elevators
			ArrayList<ElevatorWorker> allElevators = null;
			allElevators.addAll(gd.downElevators);
			allElevators.addAll(gd.upElevators);
			allElevators.addAll(gd.freeElevators);
			
			for(int i = 0; i < allElevators.size(); i++){
				try {
					allElevators.remove(i).send(0);// 0 = status check 
				} catch (IOException e) {
					e.printStackTrace();
				} 
			}
		}
	}

}
